﻿using Fiddler;
using ProgramCat.EPlug;
using ProgramCat.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using V8.Net;
namespace ProgramCat.FiddlerExtension
{
    public class FiddlerExtensionEntry : IFiddlerExtension, IAutoTamper
    {
        //这是一个标签页
        private TabPage tabPage;
        //插件的主页面
        PropertiesCatControl propertiesCatControl;

        public FiddlerExtensionEntry()
        {
            

        }
        /// <summary>
        /// 实现FD接口 插件载入
        /// </summary>
        public void OnLoad()
        {
            FiddlerApplication.UI.tabsViews.ImageList.Images.Add("icon", Resources.icon);
            this.tabPage = new TabPage("编程猫专用插件");
            this.tabPage.ImageKey = "icon";
            this.tabPage.ImageIndex = FiddlerApplication.UI.tabsViews.ImageList.Images.Count-1;
            this.propertiesCatControl = new PropertiesCatControl();
            propertiesCatControl.Dock = DockStyle.Fill;
            this.tabPage.Controls.Add(this.propertiesCatControl);
            FiddlerApplication.UI.tabsViews.TabPages.Insert(4, this.tabPage);
            FiddlerApplication.UI.tabsViews.ShowToolTips=true;
            this.tabPage.ToolTipText = "编程猫专用插件 QQ群:747776374";
        }
        /// <summary>
        /// 插件卸载
        /// </summary>
        public void OnBeforeUnload()
        {


        }
        /// <summary>
        /// Request 开始事件
        /// </summary>
        /// <param name="oSession"></param>
        public void AutoTamperRequestBefore(Session oSession)
        {
            //调用第三方DLL处理
            PlugCoreMgr.Instance.OnRequest(oSession);

        }

        public void AutoTamperRequestAfter(Session oSession)
        {
           

        }
        /// <summary>
        /// Response 开始事件
        /// </summary>
        /// <param name="oSession"></param>
        public void AutoTamperResponseBefore(Session oSession)
        {
            //调用内部JSHook模块
            JsHookMgr.Instance.OnResponse(oSession);

        }

        public void AutoTamperResponseAfter(Session oSession)
        {
           

        }

        public void OnBeforeReturningError(Session oSession)
        {
            

        }
    }
}
